class AddCertificate < Mutations::Command
  include Wisper::Publisher

  required do
    string :name
    integer :available_months
  end

  optional do
    float :initiate_cost
    float :recheck_cost
    integer :recheck_time
  end
  
  def execute
    certificate = Certificate.new inputs
    if certificate.save
      return certificate
    else
      certificate.errors.each do |key, value|
        add_error(key, key, value)
      end
    end
  end

end